<?php
class ProductRelatedService extends BaseDbService
{
	public function __construct()
	{
		$this->dao				= new ProductRelatedDao();
	}
	
	public function get($iid,$type=1)
	{
		$condition['expression'] 	= "iid = :iid and type = :type";
		$condition['value']['iid'] 	= $iid;
		$condition['value']['type'] = $type;
		$info	= $this->fetch($condition);
		if(!$info)
		{
			return false;
		}
		$info['con']	= json_decode($info['val'],true);
		
		return $info;
	}
	
	public function add($data)
	{
		$data['val']	= json_encode($data['con']);
		unset($data['con']);
		return parent::add($data);
	}
	
	public function update($id,$data)
	{
		$val	= json_encode($data['con']);
		parent::update($id,array('val'=>$val));
	}
}
?>